package monitoringMod.service;

import java.util.List;

import monitoringMod.dao.MonitoringModDAO;
import monitoringMod.util.Utilities;
import ttp.to.ChemicalTO;
import ttp.to.CrushTO;
import ttp.to.CuttingTO;
import ttp.to.DryingTO;
import ttp.to.TreeTO;

public class MonitoringModService {
	private MonitoringModDAO monitoringDao;
	public MonitoringModService(MonitoringModDAO monitoringDao){
		this.monitoringDao = monitoringDao;
	}
	
	public List<TreeTO> selectAllSuccessTree(int result) throws Exception{//tree 전체 검색
		List<TreeTO> list = monitoringDao.selectAllSuccessTree(result);
		for(int i=0; i<list.size(); i++){
			String time = Utilities.changeShortDayTimeFormat((String)list.get(i).getOrderDate());
			list.get(i).setOrderDate(time);
		}
		return list;
	}
	
	public List<CrushTO> selectAllSuccessCrush(int result) throws Exception{ // p1 전체 검색
		List<CrushTO> list =  monitoringDao.selectAllSuccessCrush(result);
		for(int i=0; i<list.size(); i++){
			String time = Utilities.changeShortDayTimeFormat((String)list.get(i).getProductDate());
			list.get(i).setProductDate(time);
		}
		return list;
		
	}

	
	public List<ChemicalTO> selectAllSuccessChemical(int result) throws Exception{ // p2 전체 검색
		List<ChemicalTO> list =  monitoringDao.selectAllSuccessChemical(result);
		for(int i=0; i<list.size(); i++){
			String time = Utilities.changeShortDayTimeFormat((String)list.get(i).getProductDate());
			list.get(i).setProductDate(time);
		}
		return list;
	}

	
	public List<DryingTO> selectAllSuccessDrying(int result) throws Exception{ // p3 전체 검색
		List<DryingTO> list =  monitoringDao.selectAllSuccessDrying(result);
		for(int i=0; i<list.size(); i++){
			String time = Utilities.changeShortDayTimeFormat((String)list.get(i).getProductDate());
			list.get(i).setProductDate(time);
		}
		return list;
	}

	
	public List<CuttingTO> selectAllSuccessCutting(int result) throws Exception{ // p4 전체 검색
		List<CuttingTO> list =  monitoringDao.selectAllSuccessCutting(result);
		for(int i=0; i<list.size(); i++){
			String time = Utilities.changeShortDayTimeFormat((String)list.get(i).getProductDate());
			list.get(i).setProductDate(time);
		}
		return list;
	}

	public int treeCountMonitoringEnterprise(String enterprise)throws Exception{
		  int cnt = monitoringDao.treeCountMonitoringEnterprise(enterprise); 
		  return cnt;
		 }
	
	public int paperCountMonitoringEnterprise(String enterprise)throws Exception{
		  int cnt = monitoringDao.paperCountMonitoringEnterprise(enterprise);
		  return cnt;
	}
	
	public int treePerPageCountMonitoringTreeType(String treeType)throws Exception{
		int cnt = monitoringDao.treePerPageCountMonitoringTreeType(treeType);
		return cnt;
	}
	
}
